﻿using System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NHibernate;
using NHibernate.Cfg;
using System.Text.RegularExpressions;

public partial class MasterPage2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private string m_Titulo;
    public string Titulo
    {
        get
        {
            return m_Titulo;
        }
        set
        {
            m_Titulo = value;
            
        }
    }

    /// <summary>
    /// Busca todas las facturas cobradas para una fecha dada
    /// </summary>
    /// <returns>void</returns>
 
      protected void ConsultarFactura()
    {
        IList infofacturas = null;
        FacturaControl fc = new FacturaControl();
        infofacturas = fc.BuscarFacturasFechaCobrada(this.Date3.Text);
        int totalrow = infofacturas.Count;
        if (totalrow == 0)
        {
            this.GridView1.Columns.Clear();
            this.GridView1.EmptyDataText = "No existen Facturas Cobradas para esta fecha"+ this.Date3.Text;
            this.GridView1.DataSource = infofacturas;
            this.GridView1.DataBind();
            this.Button2.Enabled = false;
        }
        else {
            this.GridView1.Caption = "Reporte de Facturas Cobradas el " + this.Date3.Text;
            this.Button2.Enabled = true;
            GridView1.DataSource = infofacturas;
            GridView1.DataBind();
        }
    }
      /// <summary>
      /// Controla la paginación del GridView
      /// </summary>
      /// <returns>void</returns>
 
    protected void CambioPagina(object sender, GridViewPageEventArgs e)
      {

          GridView1.PageIndex = e.NewPageIndex;
          this.ConsultarFactura();
          
      }
      protected void ValidarFormato(object sender, EventArgs e)
      {
               ConsultarFactura();     
      }
      protected void ExportarFacCobradas(object sender, EventArgs e)
      {
          ExportarReporte exporto = new ExportarReporte();
          exporto.ExportarCsv(this.GridView1, "FacturasCobradas"+this.Date3.Text, this.Page);
      }
      
}


